﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            int max = 0;
            int min = 100;
            int avg = 0;
            int sum = 0;
            //ref 一点要赋值，out 不用，
            Vs(ref  max, ref min, ref avg, ref sum);
            Console.WriteLine("最大值:{0} 最小值：{1} 平均值：{2} 总值：{3}",max,min,avg,sum);
            Vs2(out max, out min, out avg, out sum);
        }
         public static void Vs( ref int max,ref int min,ref int avg ,ref int sum)
        {
            int[] arr = new int[] { 1, 2, 3 };
 
            int num = 0; 
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i] > max) { max = arr[i]; }
                if (arr[i] < min) { min = arr[i];}
                sum = sum + arr[i];
                num++;
            }
            avg = sum / num;
          
            
        }
        //out 一定要有值传出
        public static void Vs2(out int max, out int min, out int avg, out int sum)
        {
            int[] arr = new int[] { 1, 2, 3 };

            int num = 0;
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i] > max) { max = arr[i]; }
                if (arr[i] < min) { min = arr[i]; }
                sum = sum + arr[i];
                num++;
            }
      
            avg = sum / num;


        }

    }
}
